extends MeshInstance3D

func _enter_tree() -> void:
	mesh = ArrayMesh.new()
	var arrays = []
	arrays.resize(ArrayMesh.ARRAY_MAX)
	
	var vertices = PackedVector3Array()
	vertices.push_back(Vector3(-0.5, -0.5, -0.5))
	vertices.push_back(Vector3(-0.5, -0.5,  0.5))
	vertices.push_back(Vector3(-0.5,  0.5, -0.5))
	vertices.push_back(Vector3(-0.5,  0.5,  0.5))
	vertices.push_back(Vector3( 0.5, -0.5, -0.5))
	vertices.push_back(Vector3( 0.5, -0.5,  0.5))
	vertices.push_back(Vector3( 0.5,  0.5, -0.5))
	vertices.push_back(Vector3( 0.5,  0.5,  0.5))
	
	var indices = PackedInt32Array()
	indices.push_back(0)
	indices.push_back(1)
	indices.push_back(0)
	indices.push_back(2)
	indices.push_back(0)
	indices.push_back(4)
	indices.push_back(7)
	indices.push_back(6)
	indices.push_back(7)
	indices.push_back(5)
	indices.push_back(7)
	indices.push_back(3)
	indices.push_back(3)
	indices.push_back(1)
	indices.push_back(3)
	indices.push_back(2)
	indices.push_back(5)
	indices.push_back(1)
	indices.push_back(5)
	indices.push_back(4)
	indices.push_back(6)
	indices.push_back(2)
	indices.push_back(6)
	indices.push_back(4)
	
	arrays[ArrayMesh.ARRAY_VERTEX] = vertices
	arrays[ArrayMesh.ARRAY_INDEX] = indices
	mesh.add_surface_from_arrays(Mesh.PRIMITIVE_LINES, arrays)
